select  
	id,
	time,
	price,
	case when c1=='+' then '波峰'	--趋势是+为波峰
	else '波谷' end					--趋势是-为波谷
from (
	select 
		id,
		time,
		nvl(lag(price) over(partition by id order by unix_timestamp(time,'MM:ss')),0), 	--上一个时间段价格
		price,																			--当前时间段价格
		nvl(lead(price) over(partition by id order by unix_timestamp(time,'MM:ss')),0),	--下一个时间段价格
		case when (price-nvl(lag(price) over(partition by id order by unix_timestamp(time,'MM:ss')),0)) > 0 then '+'
		else '-' end as c1,															--上一段到当前段价格的趋势
		case when (nvl(lead(price) over(partition by id order by unix_timestamp(time,'MM:ss')),0) - price) > 0 then '+'
		else '-' end as c2															--当前段到下一段价格的趋势
	from t2)tmp
where c1 != c2;	--只有在上一段到当前段价格的趋势和当前段到下一段价格的趋势不同时，才会出现波峰和波谷